{extend name="default:layout:base" /}

{block name="main"}
<div class="layui-row info-simple">
    <div class="layui-col-xs1 tc">
        <img src="{$mp.head_img}" alt="{$mp.nick_name}" class="head_img">
    </div>
    <div class="layui-col-xs7 tl">
        <p>{$mp.nick_name}</p>
        <p class="color-gray">{$mp.type_desc}</p>
    </div>
    <div class="layui-col-xs2">
        <div class="layui-btn-group">
            {if $mp.appsecret}
            <a href="{:url('edit', ['id' => $mp['id']])}" class="layui-btn layui-btn-sm layui-btn-normal">编辑</a>
            {else/}
            <a href="javascript:;"  data-href="{:$auth_url}" class="layui-btn layui-btn-sm js-auth">重新授权</a>
            {/if}
            {if $mp['status']}
            <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger js-forbid">停用</a>
            {else}
            <a href="javascript:;" class="layui-btn layui-btn-sm js-forbid layui-bg-green">启用</a>
            {/if}
        </div>
    </div>
</div>

<div class="layui-tab">
    <ul class="layui-tab-title">
        <li class="layui-this">基本信息</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <table class="layui-table" lay-skin="line" >
                <thead>
                <tr>
                    <th>小程序资料</th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>AppID</td>
                    <td>{$mp.appid}</td>
                </tr>
                {if !empty($mp['appsecret'])}
                <tr>
                    <td>AppSecret</td>
                    <td>{$mp.appsecret}</td>
                </tr>
                {/if}
                <tr>
                    <td>微信号</td>
                    <td>{$mp.alias}</td>
                </tr>
                <tr>
                    <td>原始ID</td>
                    <td>{$mp.user_name}</td>
                </tr>
                <tr>
                    <td>接入方式</td>
                    <td>{$mp.appsecret ? "手动接入" : "授权接入"}</td>
                </tr>
                <tr>
                    <td>接入时间</td>
                    <td>{$mp['create_time']}</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
{/block}

{block name="js"}

<script>
    layui.use(['element', 'jquery'], function(){
        var element = layui.element,
        $ = layui.jquery;

        //点击启用/禁用
        $('.js-forbid').on('click', function () {
            layer.confirm('确定'+($(this).text())+'吗？', {
                title: '提示',
                btn: ['是','不'] //按钮
            }, function(){
                layer.load(1);
                $.post("{:url('setStatus')}", {'ids': "{$mp.id}", val: "{$mp.status}"}, function (res) {
                    if(res.code === 1){
                        layer.msg(res.msg, {time: 1000}, function (index) {
                            location.reload();
                        });
                    }else{
                        layer.alert(res.msg);
                    }
                })
            });
        });

        $('.js-auth').on('click', function () {
            top.location.href = $(this).data('href');
        })
    });
</script>
{/block}

{block name="css"}
<style>
    .color-gray{color: #B2B2B2;}
    .info-simple{
        margin-top: 10px;
        height: 50px;
        padding: 20px 15px;
        margin-bottom: 30px;
        border: 1px solid #e7e7eb;
        background-color: #f8f8f8;
    }
    .head_img{width: 55px; height: 55px;}
    .layui-btn-group{margin-top: 7px;}
</style>
{/block}